#include <QCoreApplication>
#include <QSharedPointer>
#include <iostream>
#include "Abstractcontroller.h"
#include "Controller.h"
#include "Abstractmodel.h"
#include "Model.h"
#include "View.h"

typedef QSharedPointer<AbstractModel<double> > AbstractModelPtr;
typedef QSharedPointer<AbstractController<double> > AbstractControllerPtr;
typedef QSharedPointer<Observer_I<double> > ObserverPtr;
typedef QSharedPointer<View> ViewPtr;

int main()
    {
    AbstractModelPtr ptrModel(new Model());
    AbstractControllerPtr ptrController(new Controller(ptrModel));
    ObserverPtr ptrObserver(new View(ptrController));
    ptrModel.data()->addObserver(ptrObserver);
    ViewPtr ptrView = qSharedPointerDynamicCast<View>(ptrObserver);
    while(true)
        {
        double d = 0.0;
        std::cout<<"enter a number : ";
        std::cin >> d;
        if(d == 100.0)
            {
            break;
            }
        else if (d == 0.0)
            {
            ptrView.data()->c();
            }
        else
            {
            ptrView.data()->click(d);
            }
        }

    return 0;
    }
